POV-Ray : Newsgroups : povray.binaries.images : Question on introducing randomness. : Re: Question on introducing randomness. Server Time
18 Aug 2024 08:27:44 EDT (-0400)
  Re: Question on introducing randomness.  
From: Dave Blandston
Date: 12 May 2001 20:05:42
Message: <3afdcfd6@news.povray.org>
Random numbers are lots of fun. Generally, you need to multiply the random
number by some amount and then add or subtract a constant in order to get
random numbers within the range that you want. For example, if you want real
random numbers between 20 and 25, you could do this:
    #local NewZ = rand (MySeed) * 5 + 20;

If you want integer random numbers between -3 and 3, you could do this:
    #local NewZ = int (rand (MySeed) * 7) - 3;

Here's one more example: To get numbers between .2 and .3, you could use
this:
    #local NewZ = rand (MySeed) * .1 + .2;

Have fun,
Dave Blandston
--------------------------------------

"Thomas Lake" <tla### [at] homecom> wrote in message
news:3afdcb2e$1@news.povray.org...
> In my previous post I talked about adding random translation/rotation into
> my tunnel building script. I've played around with the rand() function
with
> mixed results. From what I understand it works like so
>
> #declare myseed = seed(12);
>
> translate <0,0,rand(myseed)>
>
> The problem with this is that the random value you get is only between 0
and
> 1. SO I tried the following.
>
> translate <0,0,rand(myseed)/rand(myseed)> or
> translate <0,0,rand(myseed)/rand(myseed)*rand(myseed)>
>
> This does work better but I still don't get the effect I want. With this
> method most of the objects are still only translated an imperceptible
> amount, and then every once in a while an object will be translated a
large
> distance. What I want is for all the objects to be noticeably translated a
> random amount, but I don't want any sudden leaps.
>
>


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.